package com.weikuang.fareast.activityNew;

import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jzxiang.pickerview.TimePickerDialog;
import com.jzxiang.pickerview.data.Type;
import com.jzxiang.pickerview.listener.OnDateSetListener;
import com.licheedev.myutils.LogPlus;
import com.trello.rxlifecycle2.android.ActivityEvent;
import com.weikuang.fareast.R;
import com.weikuang.fareast.activity.BaseActivity;
import com.weikuang.fareast.adapter.QueryHkAdapter;
import com.weikuang.fareast.bean.BranchCodeList;
import com.weikuang.fareast.bean.BranchListByCustomer;
import com.weikuang.fareast.bean.ChangOrderBean;
import com.weikuang.fareast.bean.CustomerBean;
import com.weikuang.fareast.bean.DriverListBean;
import com.weikuang.fareast.bean.GoodsBean;
import com.weikuang.fareast.bean.HotelBean;
import com.weikuang.fareast.bean.OrderListBean;
import com.weikuang.fareast.bean.OrderNoInfoBean;
import com.weikuang.fareast.bean.OutGoodsBean;
import com.weikuang.fareast.bean.PrintOrderOutBean;
import com.weikuang.fareast.bean.QueryInAndOutInfoBean;
import com.weikuang.fareast.network.KillerApi;
import com.weikuang.fareast.network.MainApi;
import com.weikuang.fareast.network.MyObserve;
import com.weikuang.fareast.utils.UserHelper;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.dlc.commonlibrary.ui.adapter.BaseRecyclerAdapter;
import cn.dlc.commonlibrary.ui.widget.CommonItemView;
import cn.dlc.commonlibrary.ui.widget.TitleBar;
import cn.dlc.commonlibrary.ui.widget.popup.CommonPopupList;
import cn.dlc.commonlibrary.utils.TimeFormats;
import cn.dlc.commonlibrary.utils.ToastUtil;
import cn.dlc.commonlibrary.utils.rv_tool.RecyclerViewUtil;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

//香港的查询
public class QueryhkActivity extends BaseActivity implements OnDateSetListener {
    @BindView(R.id.mTitleBar)
    TitleBar mTitleBar;

    @BindView(R.id.mRecyclerView)
    RecyclerView mRecyclerView;
    @BindView(R.id.btn_goods)
    Button btnGoods;

    @BindView(R.id.start_time)
    CommonItemView startTime;
    @BindView(R.id.end_time)
    CommonItemView endTime;

    @BindView(R.id.tv_customer)
    TextView tvCustomer;
    @BindView(R.id.drop_customer)
    FrameLayout dropCustomer;
    @BindView(R.id.item_customer)
    CommonItemView itemCustomer;
    @BindView(R.id.tv_group)
    TextView tvGroup;
    @BindView(R.id.drop_group)
    FrameLayout dropGroup;
    @BindView(R.id.item_group)
    CommonItemView itemGroup;

    @BindView(R.id.tv_driver)
    TextView tvDriver;   //司机
    @BindView(R.id.drop_driver)
    FrameLayout dropDriver;
    @BindView(R.id.item_driver)
    CommonItemView itemDriver;

    @BindView(R.id.ll_in_goods)
    LinearLayout ll_in_goods;
    @BindView(R.id.iv_in_goods)
    ImageView iv_in_goods;

    @BindView(R.id.ll_out_goods)
    LinearLayout ll_out_goods;
    @BindView(R.id.iv_out_goods)
    ImageView iv_out_goods;

    @BindView(R.id.tv_delivery_time)
    TextView tvDeliveryTime;   //收货时间
    @BindView(R.id.drop_delivery_time)
    FrameLayout dropDeliveryTime;
    @BindView(R.id.item_delivery_time)
    CommonItemView itemDeliveryTime;

    @BindView(R.id.tv_number)
    TextView tvNumber;   //分行编号
    @BindView(R.id.drop_number)
    FrameLayout dropNumber;
    @BindView(R.id.item_number)
    CommonItemView itemNumber;

    @BindView(R.id.tv_order)
    TextView tvOrder;
    @BindView(R.id.drop_order)
    FrameLayout dropOrder;
    @BindView(R.id.item_order)
    CommonItemView itemOrder;
    @BindView(R.id.btn_dayin)
    Button btn_dayin;

    @BindView(R.id.tv_remark)
    TextView tv_remark;

    @BindView(R.id.tv_nums)
    TextView tv_nums;   //总数

    private CommonPopupList mCustomerPopup, mGropPopup,mDriverPopup,mDeliveryTimePopup,mNumberPopup,mOrderPopup;
    private List<CustomerBean.DataBean> mCustomerList = new ArrayList<>();
    private List<BranchListByCustomer.DataBean> mGropList = new ArrayList<>();
    private List<DriverListBean.DataBean> mDriverList = new ArrayList<>();
    private List<String> mDeliveryTimeList = new ArrayList<>();

    private List<ChangOrderBean.DataBean> mOrderList = new ArrayList<>();

    private String customerId = "",branchId="",driverId = "",deliveryTime="",orderNo="";

    private QueryHkAdapter mQueryAdapter;
    List<GoodsBean> datasList = new ArrayList<>();
    private int type = 0;
    TimePickerDialog mDialogYearMonthDay;

    private boolean in_out = true;

    BranchCodeList.DataBean branchCodeBean;
    private PrintOrderOutBean printOrderOutBean;
    private String branchCode = "";//分行代码
    public String remark;
    public String inboundDate;//入库日期
    public String outboundDate;//出库日期
    public String address;//客户地址
    public String branchContactNumber;//电话

    @Override
    protected int getLayoutId() {
        return R.layout.activity_query_hk;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
        mTitleBar.leftExit(this);
        initView();
        InitRecyclerView();
        iv_in_goods.setSelected(true);
        mDeliveryTimeList = Arrays.asList(getActivity().getResources().getStringArray(R.array.week));
        btn_dayin.setVisibility(View.GONE);
        mDeliveryTimePopup.setData(mDeliveryTimeList);
    }

    private void initView() {
        mDriverPopup = CommonPopupList.newBuilder(this)
                .setWidthEquals(dropDriver)
                .setOnSelectItemListener(new CommonPopupList.OnSelectItemListener() {
                    @Override
                    public void onSelectItem(CommonPopupList popup, String item, int position) {
                        popup.dismiss();
                        customerId = "";
                        tvCustomer.setText(getString(R.string.order_1));
                        mCustomerList.clear();
                        tvGroup.setText(getString(R.string.order_2));
                        branchId = "";
                        mGropList.clear();
                        tvDriver.setText(item);
                        if (mDriverList != null) {
                            driverId = mDriverList.get(position).getDriverCode();
                            getCustomerList(UserHelper.get().getUserid(),driverId);
                        }

                    }
                })
                .build();

        mCustomerPopup = CommonPopupList.newBuilder(this)
                .setWidthEquals(dropCustomer)
                .setOnSelectItemListener(new CommonPopupList.OnSelectItemListener() {
                    @Override
                    public void onSelectItem(CommonPopupList popup, String item, int position) {
                        popup.dismiss();
                        tvCustomer.setText(item);

                        if (mCustomerList != null) {
                            // getOffice(mHospitalList.get(position).id);
                            customerId = String.valueOf(mCustomerList.get(position).getId());
                            getBranchListByCustomer(customerId);
                        }

                    }
                })
                .build();

        mGropPopup = CommonPopupList.newBuilder(this)
                .setWidthEquals(dropGroup)
                .setOnSelectItemListener(new CommonPopupList.OnSelectItemListener() {
                    @Override
                    public void onSelectItem(CommonPopupList popup, String item, int position) {
                        popup.dismiss();
                        tvGroup.setText(item);
                        if (mGropList != null) {
                            branchId = String.valueOf(mGropList.get(position).getId());
                            branchCode = mGropList.get(position).getBranchCode();
                            getorder_No();
                        }

                    }
                })
                .build();
        mDeliveryTimePopup = CommonPopupList.newBuilder(this)
                .setWidthEquals(dropDeliveryTime)
                .setOnSelectItemListener(new CommonPopupList.OnSelectItemListener() {
                    @Override
                    public void onSelectItem(CommonPopupList popup, String item, int position) {
                        popup.dismiss();
                        customerId = "";
                        tvCustomer.setText(getString(R.string.order_1));
                        mCustomerList.clear();
                        tvGroup.setText(getString(R.string.order_2));
                        branchId = "";
                        mGropList.clear();
                        List<String> datas = new ArrayList<>();
                        mCustomerPopup.setData(datas);

                        tvDeliveryTime.setText(item);
                        if (mDeliveryTimeList != null) {
                            deliveryTime = mDeliveryTimeList.get(position);
                            getCustomerList(UserHelper.get().getUserid(),driverId);
                        }

                    }
                })
                .build();

        mNumberPopup = CommonPopupList.newBuilder(this)
                .setWidthEquals(dropNumber)
                .setOnSelectItemListener(new CommonPopupList.OnSelectItemListener() {
                    @Override
                    public void onSelectItem(CommonPopupList popup, String item, int position) {
                        popup.dismiss();

                    }
                })
                .build();

        mOrderPopup = CommonPopupList.newBuilder(this)
                .setWidthEquals(dropOrder)
                .setOnSelectItemListener(new CommonPopupList.OnSelectItemListener() {
                    @Override
                    public void onSelectItem(CommonPopupList popup, String item, int position) {
                        popup.dismiss();
                        tvOrder.setText(item);
                        if (mOrderList != null) {
                            orderNo = String.valueOf(mOrderList.get(position).orderNo);
                           // getInOrderDetailList(order_id);
                        }

                    }
                })
                .build();

        mDialogYearMonthDay = new TimePickerDialog.Builder()
                .setType(Type.YEAR_MONTH_DAY)
                .setCallBack(this)
                .build();
    }

    private void InitRecyclerView() {
        mQueryAdapter = new QueryHkAdapter();
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        mRecyclerView.setLayoutManager(linearLayoutManager);
        RecyclerViewUtil.setDefaultDivider(mRecyclerView, linearLayoutManager);
        mRecyclerView.setAdapter(mQueryAdapter);
        mQueryAdapter.setOnItemClickListener(new BaseRecyclerAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(ViewGroup parent, BaseRecyclerAdapter.CommonHolder holder, int position) {

            }
        });
        getDriverList();
        getCustomerList(UserHelper.get().getUserid(),driverId);
    }


    @OnClick({R.id.drop_customer, R.id.drop_group,R.id.drop_driver,R.id.drop_order,R.id.btn_goods, R.id.start_time, R.id.end_time,R.id.drop_delivery_time,R.id.ll_in_goods,R.id.ll_out_goods, R.id.drop_number,
    R.id.btn_dayin,R.id.btn_orderno})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_in_goods:
                iv_in_goods.setSelected(true);
                iv_out_goods.setSelected(false);
                in_out = true;
                orderNo = "";
                tvOrder.setText(orderNo);
                mOrderList.clear();
                getorder_No();
                btn_dayin.setVisibility(View.GONE);
                tv_nums.setText("");
                break;
            case R.id.ll_out_goods:
                iv_in_goods.setSelected(false);
                iv_out_goods.setSelected(true);
                in_out = false;
                orderNo = "";
                tvOrder.setText(orderNo);
                mOrderList.clear();
                getorder_No();
                tv_nums.setText("");
                break;
            case R.id.drop_customer:
                mCustomerPopup.showAsDropDown(view);
                break;
            case R.id.drop_group:
                mGropPopup.showAsDropDown(view);
                break;
            case R.id.drop_driver:
                mDriverPopup.showAsDropDown(view);
                break;
            case R.id.btn_goods:
                countQuery();
                break;
            case R.id.drop_order:
                mOrderPopup.showAsDropDown(view);
                break;
            case R.id.drop_delivery_time:
                mDeliveryTimePopup.showAsDropDown(view);
                break;
            case R.id.start_time:
                type = 1;
                mDialogYearMonthDay.show(getSupportFragmentManager(), "year_month_day");
                break;
            case R.id.end_time:
                type = 2;
                mDialogYearMonthDay.show(getSupportFragmentManager(), "year_month_day");

                break;
            case R.id.drop_number:
                startActivityForResult(new Intent(getActivity(), NumberActivity.class),2001);
                break;
            case R.id.btn_dayin:
                printData();
                break;
            case R.id.btn_orderno:

                Intent intent = new Intent(getActivity(), OrderNoActivity.class);
                String start = startTime.getContentText();
                if (TextUtils.isEmpty(start)|| start.contains("請") || start.contains("時間")){
                    start = "";
                }
                String end = endTime.getContentText();
                if (end.contains("請") || start.contains("時間")){
                    end = "";
                }
                String state = "";
                if (in_out){
                    state = "in";
                }else {
                    state = "out";
                }
                OrderNoInfoBean orderNoInfoBean = new OrderNoInfoBean(branchId,customerId,start,end,state);
                intent.putExtra("datas",orderNoInfoBean);
                startActivityForResult(intent,2002);
                break;
        }
    }


    private void printData(){
        ////////////////////////////////////////出货单数据传递到打印界面
        List<PrintOrderOutBean.OrderOutDetailsBean> printlList = new ArrayList<>();
        printOrderOutBean = new PrintOrderOutBean();
        for (int i = 0;i < mQueryAdapter.getData().size();i++){
            QueryInAndOutInfoBean.DataBean goodsBean = mQueryAdapter.getData().get(i);
            PrintOrderOutBean.OrderOutDetailsBean bean = new PrintOrderOutBean.OrderOutDetailsBean(goodsBean.debtCount,goodsBean.num,goodsBean.quantityCount+goodsBean.supplementCount, goodsBean.supplementCount,goodsBean.productName);
            printOrderOutBean.order_No = goodsBean.orderNo;
            printlList.add(bean);
        }
        printOrderOutBean.setOrderOutDetails(printlList);
        printOrderOutBean.customerName = tvCustomer.getText().toString();
        printOrderOutBean.code = branchCode;
        printOrderOutBean.remark = remark;
        printOrderOutBean.inboundDate = inboundDate;
        printOrderOutBean.outboundDate = outboundDate;
        printOrderOutBean.address = address;
        printOrderOutBean.branchContactNumber = branchContactNumber;
        Intent mIntent = new Intent(getActivity(), OrderDetalisHkActivity.class);
        mIntent.putExtra("data", printOrderOutBean);
        startActivityForResult(mIntent, 2002);
        LogPlus.e("printOrderOutBean="+printOrderOutBean.toString());
    }


    private void getCustomerList(String userid,String driverCode) {

        MainApi.getInstance().getApi( KillerApi.class)
                .getCustomer(userid,driverCode,deliveryTime)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .compose(bindUntilEvent(ActivityEvent.DESTROY))
                .subscribe(new MyObserve<CustomerBean>() {
                    @Override
                    public void onNetError(Throwable e) {
                        showOneToast(getString(R.string.order_34));
                    }

                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(CustomerBean customerBean) {
                        List<String> datas = new ArrayList<>();
                        mCustomerList = customerBean.getData();
                        if (customerBean.getData()!= null && customerBean.getData().size() == 0){
                            ToastUtil.show(getActivity(),getString(R.string.order_57));
                        }
                        for (CustomerBean.DataBean bean : customerBean.getData()) {
                            datas.add(bean.getName());
                        }
                        mCustomerPopup.setData(datas);
                    }
                });
    }

    private void getBranchListByCustomer(String customerId) {
        tvGroup.setText(getString(R.string.order_2));
        branchId = "";
        MainApi.getInstance().getApi( KillerApi.class)
                .getBranchListByCustomer(UserHelper.get().getUserid(),customerId,driverId,deliveryTime)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .compose(bindUntilEvent(ActivityEvent.DESTROY))
                .subscribe(new MyObserve<BranchListByCustomer>() {
                    @Override
                    public void onNetError(Throwable e) {
                        showOneToast(getString(R.string.order_34));
                    }

                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(BranchListByCustomer branchListByCustomer) {
                        List<String> datas = new ArrayList<>();
                        mGropList = branchListByCustomer.getData();
                        if (branchListByCustomer.getData()!= null && branchListByCustomer.getData().size() == 0){
                            ToastUtil.show(getActivity(),getString(R.string.order_57));
                        }
                        for (BranchListByCustomer.DataBean bean : branchListByCustomer.getData()) {
                            datas.add(bean.getBranchName());
                        }
                        mGropPopup.setData(datas);
                    }
                });
    }

    private void getDriverList() {

        MainApi.getInstance().getApi( KillerApi.class)
                .getDriverList(UserHelper.get().getUserid())
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .compose(bindUntilEvent(ActivityEvent.DESTROY))
                .subscribe(new MyObserve<DriverListBean>() {
                    @Override
                    public void onNetError(Throwable e) {
                        showOneToast(getString(R.string.order_34));
                    }

                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(DriverListBean customerBean) {
                        List<String> datas = new ArrayList<>();
                        mDriverList = customerBean.getData();
                        if (customerBean.getData()!= null && customerBean.getData().size() == 0){
                            ToastUtil.show(getActivity(),getString(R.string.order_57));
                        }
                        for (DriverListBean.DataBean bean : customerBean.getData()) {
                            datas.add(bean.getDriverName());
                        }
                        mDriverPopup.setData(datas);
                    }
                });
    }


    private void countQuery() {
        mQueryAdapter.setNewData(null);
        String start = startTime.getContentText();
        if (TextUtils.isEmpty(start)|| start.contains("請") || start.contains("時間")){
            start = "";
        }
        String end = endTime.getContentText();
        if (end.contains("請") || start.contains("時間")){
            end = "";
        }
        String state = "";
        if (in_out){
            state = "in";
        }else {
            state = "out";
        }
        if (!in_out && !TextUtils.isEmpty(orderNo)){
            btn_dayin.setVisibility(View.VISIBLE);
        }
        LogPlus.e("orderNo="+orderNo);
        showWaitingDialog("请等待",true);
        MainApi.getInstance().getApi( KillerApi.class)
                .queryInAndOutInfo(UserHelper.get().getUserid(),branchId,UserHelper.get().getUserid(),customerId,end,start,state,orderNo)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .compose(bindUntilEvent(ActivityEvent.DESTROY))
                .subscribe(new MyObserve<QueryInAndOutInfoBean>() {
                    @Override
                    public void onNetError(Throwable e) {
                        showOneToast(getString(R.string.order_34));
                    }

                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(QueryInAndOutInfoBean branchListByCustomer) {
                        LogPlus.e("orderNo="+branchListByCustomer.toString());
                        dismissWaitingDialog();
                        mQueryAdapter.setNewData(branchListByCustomer.getData());
                        String string = "";
                        if (branchListByCustomer.getData()!= null && branchListByCustomer.getData().size() == 0){
                            ToastUtil.show(getActivity(),getString(R.string.order_57));
                        }
                        int nums = 0;
                        for (int i = 0;i < branchListByCustomer.getData().size();i++){
                            QueryInAndOutInfoBean.DataBean bean = branchListByCustomer.getData().get(i);
                            string = string + "\r\n";
                            string = string + bean.attribute+"  "+bean.productName+"  "+bean.productTypeName+"  "+bean.num;
                            remark = bean.remark;
                            inboundDate = bean.inboundDate;
                            outboundDate = bean.outboundDate;
                            address = bean.address;
                            branchContactNumber = bean.branchContactNumber;
                            if (in_out){
                                nums = nums +bean.num;
                            }else {
                                nums = nums +bean.quantityCount;
                            }
                        }
                        tv_nums.setText(nums+"");
                        tv_remark.setText(remark);

                    }
                });
    }


    /**
     * 获取订单的订单编号
     */
    private void getorder_No() {

        mQueryAdapter.setNewData(null);
        tvOrder.setText("");
        String start = startTime.getContentText();
        if (TextUtils.isEmpty(start)|| start.contains("請") || start.contains("時間")){
            start = "";
        }
        String end = endTime.getContentText();
        if (end.contains("請") || start.contains("時間")){
            end = "";
        }
        String state = "";
        if (in_out){
            state = "in";
        }else {
            state = "out";
        }
        tv_nums.setText("");
        showWaitingDialog("请等待",true);
        MainApi.getInstance().getApi( KillerApi.class)
                .getOrderList(UserHelper.get().getUserid(),branchId,UserHelper.get().getUserid(),customerId,start,end,state)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .compose(bindUntilEvent(ActivityEvent.DESTROY))
                .subscribe(new MyObserve<ChangOrderBean>() {
                    @Override
                    public void onNetError(Throwable e) {
                        showOneToast(getString(R.string.order_34));
                    }

                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(ChangOrderBean changListBean) {
                        dismissWaitingDialog();
                        List<String> datas = new ArrayList<>();
                        mOrderList.clear();
                        if (changListBean.getData()!= null && changListBean.getData().size() == 0){
                            ToastUtil.show(getActivity(),getString(R.string.order_57));
                        }
                        for (ChangOrderBean.DataBean bean : changListBean.getData()) {
                            datas.add(bean.orderNo);
                            mOrderList.add(bean);

                        }
                        mOrderPopup.setData(datas);

                    }
                });
    }





    @Override
    public void onDateSet(TimePickerDialog timePickerView, long millseconds) {
        if (type == 1) {
            startTime.setContent(TimeFormats.formatDateTime1(timePickerView.getCurrentMillSeconds()));
        } else {
            endTime.setContent(TimeFormats.formatDateTime1(timePickerView.getCurrentMillSeconds()));
            getorder_No();
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (resultCode == 4 && data != null) {

            branchCodeBean = (BranchCodeList.DataBean) data.getSerializableExtra("data");
            if (branchCodeBean != null) {
                tvNumber.setText(branchCodeBean.getBranchCode());
                tvCustomer.setText(branchCodeBean.getCustomerName());
                customerId = branchCodeBean.getCustomerId()+"";
                tvGroup.setText(branchCodeBean.getBranchName());
                branchId = branchCodeBean.getId()+"";
                branchCode = branchCodeBean.getBranchCode();
                getorder_No();
            }
        }
        if (resultCode == 5 && data != null) {

            ChangOrderBean.DataBean changOrderNo = (ChangOrderBean.DataBean) data.getSerializableExtra("data");
            if (changOrderNo != null) {

                customerId = changOrderNo.customerId + "";
                if (!TextUtils.isEmpty(changOrderNo.customerName)) {
                    tvCustomer.setText(changOrderNo.customerName);
                }
                if (!TextUtils.isEmpty(changOrderNo.branchName)) {
                    tvGroup.setText(changOrderNo.branchName);
                }
               branchCode = changOrderNo.branchCode;
                branchId = changOrderNo.branchId+"";
                tvOrder.setText(changOrderNo.orderNo);
                orderNo = changOrderNo.orderNo;
            }
        }
    }

}
